package com.pulyka.rtpvp.engine.entities.hero;

public class PoolAttribute {

	protected int maxValue;
	protected int actValue;
	protected int autoRestoreAmount;
	
	protected boolean negativeAllowed;
	
	public PoolAttribute(int maxValue, int autoRestoreAmount){
		this(maxValue, maxValue, autoRestoreAmount, false);
	}
	
	public PoolAttribute(int maxValue, int actValue, int autoRestoreAmount, boolean negativeAllowed) {
		this.maxValue = maxValue;
		this.actValue = actValue;
		this.autoRestoreAmount = autoRestoreAmount;
		this.negativeAllowed = negativeAllowed;
	}
	
	public int consume(int amount){
		actValue -= amount; 
		if(!negativeAllowed && actValue < 0){
			actValue = 0;
		}
		return actValue;
	}
	
	public int restoreAutoAmount(){
		return restore(autoRestoreAmount);
	}
	
	public int restore(int amount){
		actValue += amount;
		if(actValue > maxValue){
			actValue = maxValue;
		}
		return actValue;
	}

	public int getMaxValue() {
		return maxValue;
	}

	public void setMaxValue(int maxValue) {
		this.maxValue = maxValue;
	}

	public int getActValue() {
		return actValue;
	}

	public void setActValue(int actValue) {
		this.actValue = actValue;
	}
	
	public int getAutoRestoreAmount() {
		return autoRestoreAmount;
	}
	
	public void setAutoRestoreAmount(int autoRestoreAmount) {
		this.autoRestoreAmount = autoRestoreAmount;
	}
	
}
